{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2024-03-07T00:29:09.175444Z",
     "start_time": "2024-03-07T00:29:09.171030Z"
    }
   },
   "outputs": [],
   "source": [
    "# if语句嵌套\n",
    "number = 100\n",
    "\n",
    "if number < 100:\n",
    "    if number % 7 == 0:\n",
    "        pass\n",
    "    else:\n",
    "        pass\n",
    "else:\n",
    "    pass        "
   ]
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "data": {
      "text/plain": "[0, 49]"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# for语句嵌套\n",
    "[x * x for x in range(10) if x % 7 == 0]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-07T00:35:29.428326Z",
     "start_time": "2024-03-07T00:35:29.421948Z"
    }
   },
   "id": "6fbc172bf831c6ce",
   "execution_count": 2
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "data = [[ 1, 2, 1, 2, 0], [2, 2, 2, 1, 0], [1, 1, 2, 2, 0]]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-07T00:39:35.334686Z",
     "start_time": "2024-03-07T00:39:35.329733Z"
    }
   },
   "id": "658b635741386e8a",
   "execution_count": 3
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 2, 1, 2, 0, 2, 2, 2, 1, 0, 1, 1, 2, 2, 0]\n"
     ]
    }
   ],
   "source": [
    "list2 = []\n",
    "for i in data:\n",
    "    for j in i:\n",
    "        list2.append(j)\n",
    "\n",
    "print(list2)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-07T00:43:43.146717Z",
     "start_time": "2024-03-07T00:43:43.142342Z"
    }
   },
   "id": "f9dda4118027f4c5",
   "execution_count": 10
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "# 练习：请你使用嵌套语句在命令行打印九九乘法表。"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-09T01:16:36.991647Z",
     "start_time": "2024-03-09T01:16:36.984319Z"
    }
   },
   "id": "30aa30f4c66766a5",
   "execution_count": 1
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 * 1 = 1,\n",
      "\n",
      "1 * 2 = 2,2 * 2 = 4,\n",
      "\n",
      "1 * 3 = 3,2 * 3 = 6,3 * 3 = 9,\n",
      "\n",
      "1 * 4 = 4,2 * 4 = 8,3 * 4 = 12,4 * 4 = 16,\n",
      "\n",
      "1 * 5 = 5,2 * 5 = 10,3 * 5 = 15,4 * 5 = 20,5 * 5 = 25,\n",
      "\n",
      "1 * 6 = 6,2 * 6 = 12,3 * 6 = 18,4 * 6 = 24,5 * 6 = 30,6 * 6 = 36,\n",
      "\n",
      "1 * 7 = 7,2 * 7 = 14,3 * 7 = 21,4 * 7 = 28,5 * 7 = 35,6 * 7 = 42,7 * 7 = 49,\n",
      "\n",
      "1 * 8 = 8,2 * 8 = 16,3 * 8 = 24,4 * 8 = 32,5 * 8 = 40,6 * 8 = 48,7 * 8 = 56,8 * 8 = 64,\n",
      "\n",
      "1 * 9 = 9,2 * 9 = 18,3 * 9 = 27,4 * 9 = 36,5 * 9 = 45,6 * 9 = 54,7 * 9 = 63,8 * 9 = 72,9 * 9 = 81,\n"
     ]
    }
   ],
   "source": [
    "i = 1\n",
    "j = 1\n",
    "for i in range(1, 10):\n",
    "    for j in range(1, i+1):\n",
    "        print(f\"{j} * {i} = {i * j}\", end=\",\")\n",
    "    print(\"\\n\")"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-03-09T01:21:36.228340Z",
     "start_time": "2024-03-09T01:21:36.223586Z"
    }
   },
   "id": "3483b9c71d6d8740",
   "execution_count": 11
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "2b1d4e9dee5ad5ba"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
